<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>对接成功案例</title>


    <!-- Expand styles -->
    <link href="../css/app/app.css" rel="stylesheet">
    <link href="../css/app/default.css" rel="stylesheet">
    <link href="../css/mui/mui.css" rel="stylesheet">

</head>

<body>

    <!-- header -->
    <div>
        <div class="widget-default margin-b-5">
            <div class="farming-tab">
                <div class="index-scroll margin-b-3">
                    <div
                        class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                        <div class="mui-scroll" id="typeList">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 内容 -->
        <div id="pullrefresh" class="mui-content mui-scroll-wrapper" style="margin-top: 52px;">
            <div class="mui-scroll">
                <div id="dataList">
                    
                </div>
            </div>
        </div>
    </div>



    <script src="../js/dsbridge.js"></script>
    <script src="../js/jquery.js"></script>
    <script src="../js/mui/mui.js"></script>
    <script src="../js/mui/mui.picker.min.js"></script>
    <script src="../js/layer.js"></script>
    <script src="../js/app/app-base.js"></script>
    <script src="../js/app/app-url.js"></script>
    <script src="../js/app/app-ajax.js"></script>
    <script>
        var page = 1;
        var limit = 10;
        var index = 0;
        var all_data = new Array();
        //培训类型code
        var tranTypeCode = '';

        $(document).ready(function () {
            mui.init({
                pullRefresh: {
                    container: '#pullrefresh',
                    down: {
                        auto: true, // 首次进入自动加载
                        callback: pulldownRefresh
                    },
                    up: {
                        contentrefresh: '正在加载...',
                        callback: pullupRefresh
                    }
                }
            });
            //获取培训类型
            getTrainType();
        })


        //三级类型切换
        mui("#typeList").on('tap', '.trainType', function () {
            tranTypeCode = $(this).attr("code");
            pulldownRefresh();
        });

        //获取培训类型
        function getTrainType() {
            var data = {
                pCode:'TRAN_TYPE'
            }
            getServerData(url_businessdatamng_queryList, data);
        }

        /**
         * 下拉刷新具体业务实现
         */
        function pulldownRefresh() {
            page = 1;
            var data = {
                sourceType: 'web',
                userId: getUserId(),
                tranTypeCode: tranTypeCode,
                confirmStatus:3,
                page: page,
                limit: limit
            }
            getServerData(url_trandemandmgr_queryList, data);
        }

        /**
         * 上拉加载具体业务实现
         */
        function pullupRefresh() {
            page++;
            var data = {
                sourceType: 'web',
                userId: getUserId(),
                tranTypeCode: tranTypeCode,
                confirmStatus:3,
                page: page,
                limit: limit
            }
            getServerData(url_trandemandmgr_queryList, data);
        }

        function getServerDataSuccess(url, data) {
            switch (url) {
                case url_businessdatamng_queryList:
                    //培训类型
                    var data = data.data;
                    var h5 = '<a class="trainType mui-control-item mui-active" code="">全部</a>';
                    if(data != null && data.length > 0){
                        $.each(data,function(index,item){
                            h5 += '<a class="trainType mui-control-item" code="'+item.code+'">'+item.name+'</a>';
                        })
                    }
                    $("#typeList").html(h5);
                    break;
                case url_trandemandmgr_queryList:
                    var list = data.data;
                    if (page == 1) {
                        index = 0;
                        all_data.length = 0;
                    }
                    var h5 = '';
                    if (list != null && list.length > 0) {
                        $.each(list, function (sindex, item) {
                            all_data.push(item);
                            h5 +=
                                '<div class="margin-b-10 trade-list widget-body widget-default trainDetail" id="' +index + '" >' +
                                    '<p class="black font-15 font-weight elli1 padding-r-20">'+item.title+'</p>' +
                                    '<img class="pxsuccess-img" src="../img/px-success.png" alt="">' +
                                    '<p class="font-13 gray no-margin">发起人：'+item.tranConnectPersion+'</p>' +
                                    '<p class="font-13 gray">培训地址：'+item.tranAddressShow+'</p>' +
                                    '<p class="text-right black font-15 no-margin">'+item.budgetShow+'元<span class="gray font-13 margin-l-3">预算</span>' +
                                    '</p>' +
                                '</div>';
                            index++;
                        })
                    }
                    if (page == 1) {
                        mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
                        if (list.length > 0) {
                            mui('#pullrefresh').pullRefresh().refresh(true);
                        }
                        $("#dataList").html(h5);
                    } else {
                        $("#dataList").append(h5);
                        mui('#pullrefresh').pullRefresh().endPullupToRefresh(list.length != limit);
                    }
                    break;
            }
        }

        function getServerDataFailed(url, data) {
            mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
            mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
        }

        //详情
        mui("#dataList").on('tap', '.trainDetail', function () {
            var detailIndex = $(this).attr("id");
            localStorage.setItem("success-case-detail-id",all_data[detailIndex].id);
            dsBridge.call("goTrainSuccessCaseDetail","");
        });
    </script>
</body>

</html>